home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / code_1.zip / TEM_UDFS.PRG < prev   
Text File  |  1989-01-02  |  51KB  |  1,023 lines

  1. * SYS_UDF.PRG
  2. * User Defined Functions by Gary L. Cota
  3. *     created: 11/25/88
  4. * last update: 01/01/89
  5. *
  6. ***************************************************************************
  7. *  To Whom It May Concern:                                                *
  8. *  ---------------------------------------------------------------------  * 
  9. *  The program code contained herein is a combination of User Defined     *
  10. *  Functions (UDFs) created by myself and functions collected from        *
  11. *  other various sources.  These sources include DATA BASED ADVISOR       *
  12. *  magazine, "PROGRAMMING IN CLIPPER" (first and second editions by       *
  13. *  Stephen Straley, D.O.S.S (Desk Of Stephen Straley newsletter, the      *
  14. *  REFERENCE(CLIPPER) newsletter to name  but a few.  I make no claim     *
  15. *  to ownership of these functions.  They are available your use but      *
  16. *  with no guarantee, warranty, or royalty involved from myself.          *
  17. *                                                                         *
  18. *  NOTE:  These functions were created for use with CLIPPER SUMMER '87    *
  19. *         Version only.  It is possible that some may work with the       *
  20. *         AUTUMN '86 Version but none have been tested with that ver-     *
  21. *         sion.                                                           *
  22. *                                                                         *
  23. *  NOTE:  The function names are prefixed with a "c_" to (hopefully)      *
  24. *         make them unique to current and future versions of CLIPPER      *
  25. *         and third party UDF libraries.                                  *
  26. *                                                                         * 
  27. *         All local variables are prefixed with a "_" (underscore) as     *
  28. *         in "_in_string".  Temporary work variables are prefixed and     *
  29. *         suffixed with an underscore as in _ma_, _mb_, _mc_, etc. to     *
  30. *         hopefully prevent any duplicate program memory variable         *
  31. *         names or CLIPPER reserved words.                                *
  32. *                                                                         *
  33. *                                            Gary L. Cota  11/25/88       *
  34. ***************************************************************************
  35. *
  36. *
  37. *
  38. FUNCTION c_ALLTRIM
  39.    ************************************************************************
  40.    *  PASS:     <expC1>                                                   *
  41.    *                                                                      *
  42.    *  RETURNS:  The character string minus trimmed leading and trailing   *
  43.    *            spaces.                                                   *
  44.    *                                                                      *
  45.    *  PURPOSE:  Uses less memory space than it's CLIPPER counterpart.     *
  46.    *                                                                      *
  47.    *  EXAMPLE:  mfirst = FIRST_NAME                                       *
  48.    *            mlast  = LAST_NAME                                        *
  49.    *            ? c_ALLTRIM(mfirst)+" "+c_ALLTRIM(mlast)                  *
  50.    ************************************************************************
  51.    *
  52.    PARAMETERS _in_string
  53.    *
  54. RETURN(LTRIM(TRIM(_in_string)))
  55. *
  56. *
  57. *
  58. FUNCTION c_BLANK
  59.    ************************************************************************
  60.    *  PASS:     <expC1>, <expC2> (optional)                               *
  61.    *                                                                      *
  62.    *  RETURNS:  The empty or blank value of a .DBF field.                 *
  63.    *                                                                      *
  64.    *  PURPOSE:  Initialize blank or empty memory variables from .DBF      *
  65.    *            fields.                                                   *
  66.    *                                                                      *
  67.    *  NOTES:    If second paramater is passed, logical fields will be     *
  68.    *            initialized to .F. (false).  If a second parameter is not *
  69.    *            passed, logical fields will be initialized to a character *
  70.    *            string of SPACE(1).                                       *
  71.    *                                                                      *
  72.    *            This function may be used in conjunction with the         *
  73.    *            c_DATAGONE() and c_MEMEMPTY() UDFs.                       *
  74.    *                                                                      *
  75.    *  EXAMPLE:  mCUSTOMER = c_BLANK(CUSTOMER)                             *
  76.    *            (where mCUSTOMER is a memory variable and CUSTOMER is a   *
  77.    *            .DBF field name.                                          *
  78.    *                                                                      *
  79.    *            MBILLABLE = c_BLANK(BILLABLE)                             *
  80.    *            (memory variable is initialized to " ")                   *
  81.    *                                                                      *
  82.    *            MBILLABLE = c_BLANK(BILLABLE,x)                           *
  83.    *            (memory variable is initialized to .F.)                   *
  84.    ************************************************************************
  85.    *
  86.    PARAMETERS _in_string, _my_
  87.    *
  88.    DO CASE
  89.       CASE TYPE("_in_string")="C"
  90.          * Character
  91.          RETURN(SPACE(LEN(_in_string)))
  92.          *
  93.       CASE TYPE("_in_string")="D"
  94.          * Date
  95.          RETURN(CTOD("  /  /  "))
  96.          *
  97.       CASE TYPE("_in_string")="L"
  98.          * Logical
  99.          IF PCOUNT() = 2
  100.             *****************************************************
  101.             * Second parameter passed.  Logical memory variable *
  102.             * will be initialized to .F..                       *
  103.             *****************************************************
  104.             RETURN(.F.)
  105.          ELSE
  106.             *****************************************************
  107.             * If one parameter passed, convert logical field to *
  108.             * character memory variable of SPACE(1).            *
  109.             *****************************************************
  110.             RETURN(SPACE(1))
  111.          ENDIF
  112.          *
  113.       CASE TYPE("_in_string")="M"
  114.          * Memo
  115.          RETURN(SPACE(512))
  116.          *
  117.       CASE TYPE("_in_string")="N"
  118.          * Numeric
  119.          RETURN(0.00)
  120.          *
  121.       OTHERWISE
  122.          RETURN(.F.)
  123.    ENDCASE
  124. RETURN(0)
  125. *
  126. *
  127. *
  128. FUNCTION c_BOXIT
  129.    ************************************************************************
  130.    *  PASS:     <expN1>, <expN2>, <expN3>, <expN4>, <expN5>, <expC1>      *
  131.    *                                                                      *
  132.    *            where:   <expN1> = top row                                *
  133.    *                     <expN2> = top column                             *
  134.    *                     <expN3> = bottom row                             *
  135.    *                     <expN4> = bottom column                          *
  136.    *                     <expN5> = box type 1-4 (1 is single line box, 2  *
  137.    *                               is double line box, 3 is double line   *
  138.    *                               top and bottom and single line sides,  *
  139.    *                               and 4 is single line top and bottom    *
  140.    *                               and double line sides).                *
  141.    *                     <expC1> = optional box color parameter           *
  142.    *                                                                      *
  143.    *  RETURNS:  Nothing                                                   *
  144.    *                                                                      *
  145.    *  PURPOSE:  Clears area and displays a box or window.                 *
  146.    *                                                                      *
  147.    *  EXAMPLE:  mboxtype  = 1            && single line box               *
  148.    *            mboxcolor = "+BG/N"      && color variable                *
  149.